class MyCalendarThree {
    map<int, int> m;
public:
    MyCalendarThree() {
        
    }
    
    int book(int startTime, int endTime) {
        // 插旗法，与前两天题目一致的思路
        m[startTime] += 1;
        m[endTime] -= 1;

        // 利用map的特性，它的遍历顺序是由小到大的
        int cur = 0, k = 0;
        for(auto &cp : m)
        {
            cur += cp.second;
            k = max(k, cur);
        }
        return k;
    }
};

/**
 * Your MyCalendarThree object will be instantiated and called as such:
 * MyCalendarThree* obj = new MyCalendarThree();
 * int param_1 = obj->book(startTime,endTime);
 */